package icu.sehnen.nav.controller;


import icu.sehnen.nav.entity.Nav;
import icu.sehnen.nav.service.INavService;
import icu.sehnen.common.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author icu.sehnen
 * @since 2021-04-26
 */
@RestController
@RequestMapping("/nav")
public class NavController {
    @Autowired
    INavService navService;
    @GetMapping("/list")
    public CommonResult findAll(){
        List<Nav> navModelList=navService.list();
        return  CommonResult.success(navModelList);
    }

    @GetMapping("/find/{id}")
    public  CommonResult findNavById(@PathVariable Long id){
        Nav navModel=navService.getById(id);
        return  CommonResult.success(navModel);
    }
    @PostMapping("/add")
    public  CommonResult add(Nav nav){
        navService.save(nav);
        return  CommonResult.success();
    }
    @PostMapping("/update")
    public  CommonResult update(Nav nav){
        navService.updateById(nav);
        return  CommonResult.success();
    }
    @PostMapping("/delete/{id}")
    public  CommonResult delete(@PathVariable Long id){
        navService.removeById(id);
        return  CommonResult.success();
    }

}
